package com.lb.shopguide.adapter;

import android.graphics.Paint;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lb.shopguide.R;
import com.lb.shopguide.entity.FansBean;
import com.lb.shopguide.util.pic.ImageLoaderUtils;
import com.yqritc.recyclerviewflexibledivider.FlexibleDividerDecoration;
import com.yqritc.recyclerviewflexibledivider.HorizontalDividerItemDecoration;

import java.util.List;

/**
 * Created by kang on 2017/9/7.
 */

public class AdapterFans extends BaseQuickAdapter<FansBean, BaseViewHolder> implements HorizontalDividerItemDecoration.MarginProvider, FlexibleDividerDecoration.PaintProvider {
    public AdapterFans(@LayoutRes int layoutResId, @Nullable List<FansBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, FansBean item) {
        View view = helper.itemView;

        TextView tvFansName = view.findViewById(R.id.tv_fans_name);
        TextView tvNewFlag = view.findViewById(R.id.tv_new_flag);
        ImageView ivFansLogo = view.findViewById(R.id.iv_fans_logo);

        ImageLoaderUtils.displayCircle(mContext, ivFansLogo, item.getHeadPicUrl());
        tvFansName.setText(item.getNickName());
        if (item.isNew()) {
            tvNewFlag.setVisibility(View.VISIBLE);
        } else {
            tvNewFlag.setVisibility(View.GONE);
        }
    }

    @Override
    public Paint dividerPaint(int position, RecyclerView parent) {
        Paint paint = new Paint();
        paint.setColor(mContext.getResources().getColor(R.color.sg_common_line_bg_dark));
        paint.setStrokeWidth(2);
        return paint;
    }

    @Override
    public int dividerLeftMargin(int position, RecyclerView parent) {
        return 140;
    }

    @Override
    public int dividerRightMargin(int position, RecyclerView parent) {
        return 0;
    }
}
